package com.koron.sinoprobe.web.engineering.service;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.koron.bean.query.PageQuery;
import com.koron.sinoprobe.web.engineering.bean.po.SpEstablish;
import com.koron.sinoprobe.web.engineering.bean.query.SpEstablishQuery;
import com.koron.sinoprobe.web.engineering.bean.vo.SpEstablishVO;
import org.koron.ebs.mybatis.SessionFactory;

import java.util.List;

/**
 * 项目立项(SpEstablish)表服务接口
 *
 * @author jzp
 * @since 2021-11-30 10:06:50
 */
public interface SpEstablishService {

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    SpEstablishVO getById(SessionFactory factory, String id);

    /**
     * 通过ID查询单条数据
     *
     * @param projectId 主键
     * @return 实例对象
     */
    SpEstablish getByProjectId(SessionFactory factory, String projectId);

    /**
     * 查询所有数据
     *
     * @param query 查询条件对象
     * @return 列表结果集
     */
    List<SpEstablishVO> list(SessionFactory factory, SpEstablishQuery query);

    /**
     * 分页查询
     * @param query 分页对象
     * @return 对象列表
     */
    default PageInfo<SpEstablishVO> page(SessionFactory factory, PageQuery pageQuery, SpEstablishQuery query) {
        PageHelper.startPage(pageQuery.getPage(), pageQuery.getPageSize(), pageQuery.getOrderBy());
        List<SpEstablishVO> spEstablishList = list(factory, query);
        return new PageInfo<>(spEstablishList);
    }

    List<String> getRelated(SessionFactory factory);

    /**
     * 新增数据
     *
     * @param spEstablish 实例对象
     * @return 是否成功
     */
    boolean saveOrUpdate(SessionFactory factory, SpEstablish spEstablish);

    boolean submit(SessionFactory factory, SpEstablish spEstablish);

    boolean end(SessionFactory factory,  String id);

    /**
     * 修改数据
     *
     * @param spEstablish 实例对象
     * @return 是否成功
     */
    boolean update(SessionFactory factory, SpEstablish spEstablish);

    boolean updateStatus(SessionFactory factory, String id, String status);

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    boolean deleteById(SessionFactory factory, String id);

}
